return gtk_tree_model_iter_n_children (priv->model, NULL);
}
+static void
+adjust_wrap_width (GtkIconView *icon_view)
+{
+ if (icon_view->priv->text_cell)
+ {
+ gint wrap_width = 50;
+
+ /* Here we go with the same old guess, try the icon size and set double
+ * the size of the first icon found in the list, naive but works much
+ * of the time */
+ if (icon_view->priv->items && icon_view->priv->pixbuf_cell)
+ {
+ gtk_cell_renderer_get_preferred_width (icon_view->priv->pixbuf_cell,
+ GTK_WIDGET (icon_view),
+ &wrap_width, NULL);
+
+ wrap_width = MAX (wrap_width * 2, 50);
+ }
+
+ g_object_set (icon_view->priv->text_cell, "wrap-width", wrap_width, NULL);
+ g_object_set (icon_view->priv->text_cell, "width", wrap_width, NULL);
+ }
+}
+
static void
cell_area_get_preferred_size (GtkIconView *icon_view,
GtkCellAreaContext *context,
GtkIconViewItem *item = items->data;
_gtk_icon_view_set_cell_data (icon_view, item);
+ if (items == priv->items)
+ adjust_wrap_width (icon_view);
cell_area_get_preferred_size (icon_view, context, orientation, for_size, NULL, NULL);
}
}
}
-static void
-adjust_wrap_width (GtkIconView *icon_view)
-{
- if (icon_view->priv->text_cell)
- {
- gint wrap_width = 50;
-
- /* Here we go with the same old guess, try the icon size and set double
- * the size of the first icon found in the list, naive but works much
- * of the time */
- if (icon_view->priv->items && icon_view->priv->pixbuf_cell)
- {
- _gtk_icon_view_set_cell_data (icon_view, icon_view->priv->items->data);
- gtk_cell_renderer_get_preferred_width (icon_view->priv->pixbuf_cell,
- GTK_WIDGET (icon_view),
- &wrap_width, NULL);
-
- wrap_width = MAX (wrap_width * 2, 50);
- }
-
- g_object_set (icon_view->priv->text_cell, "wrap-width", wrap_width, NULL);
- g_object_set (icon_view->priv->text_cell, "width", wrap_width, NULL);
- }
-}
-
static gint
compare_sizes (gconstpointer p1,
gconstpointer p2,
n_items = gtk_icon_view_get_n_items (icon_view);
- /* Update the wrap width for the text cell before going and requesting sizes */
- if (n_items)
- adjust_wrap_width (icon_view);
-
gtk_icon_view_compute_n_items_for_size (icon_view,
GTK_ORIENTATION_HORIZONTAL,
gtk_widget_get_allocated_width (widget),